package com.fulong.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.fulong.common.utils.R;
import com.fulong.web.webconfig.UserStatus;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fulong.common.utils.PageUtils;
import com.fulong.common.utils.Query;

import com.fulong.dao.DeviceLendRecordDao;
import com.fulong.entity.DeviceLendRecordEntity;
import com.fulong.service.DeviceLendRecordService;


@Service("deviceLendRecordService")
public class DeviceLendRecordServiceImpl extends ServiceImpl<DeviceLendRecordDao, DeviceLendRecordEntity> implements DeviceLendRecordService {
    @Override
    public PageUtils queryOutStockPage(Map<String, Object> params) {
        //分页问题
        int currentpage  = 1 ;
        if(params.get("page")!=null) {
            currentpage = Integer.parseInt(params.get("page").toString());
            params.remove("page") ;
        }
        List<Map<String, Object>> maps = baseMapper.listApproverOutstock();
        return new PageUtils(maps , 10 , currentpage);
    }

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        //分页问题
        int currentpage  = 1 ;
        if(params.get("page")!=null) {
            currentpage = Integer.parseInt(params.get("page").toString());
            params.remove("page") ;
        }
//        HashMap<String , Object> map = new HashMap<>();
//        IPage<DeviceLendRecordEntity> page = this.page(
//                new Query<DeviceLendRecordEntity>().getPage(params),
//                new QueryWrapper<DeviceLendRecordEntity>()
//        );
        List<Map<String, Object>> maps = baseMapper.listApprover(UserStatus.getParam().getId());
        return new PageUtils(maps , 10 , currentpage);
    }

    @Override
    public boolean updateApproverRecoder() {
        boolean update = this.update(new UpdateWrapper<DeviceLendRecordEntity>().eq("status", 1).set("status", 100));
        return  update;
    }

}